#@layout()

#define content()
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:true">
        #include("/common/sa_menus.html")
    </div>
    <div data-options="region:'west',title:'字典类型'" style="width: 200px;padding: 10px;">
        <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-pill_add',plain:true" id='dictTypeAdd'>增加字典类型</a>
            #for(dictType : dictTypes)
                #if(dictType.isEnable == "1")
                    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-application_view_icons',plain:true" onclick='getDictByDictType("#(dictType.dt_id)")'>#(dictType.dt_name)</a><br>
                #end
            #end
    </div>
    <div data-options="region:'center'">
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'center',border:true">
                <div id="datagridIdExt"></div>

                <div id="datagridTbExt">
                    <div class="row">
                        <div class="row">
                            <div class="col-md-12" style="padding: 5px 25px;">
                                <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-pill_add',plain:true" id='dict_add'>增加字典</a>
                                <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-pill_go',plain:true" id='dict_edit'>编辑字典</a>
                                <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-pill_delete',plain:true" id='dict_remove'>移除字典</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

#end


#define css()

#end


#define js()


<script type="text/javascript">
    var _datagridExt = "datagridIdExt", _formExt = "formIdExt", _datagridTbExt = "datagridTbExt";
    var datagridListUrlExt = contextRootPath + '/dict/dictList';

    $(function () {

        //初始化表格
        $("#" + _datagridExt).datagrid({
            url: datagridListUrlExt,
            title:'数据字典',
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 30,
            toolbar: '#' + _datagridTbExt,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            columns: [[
                {field: DBConts.TABLE_DICT.DICT_ID,title: DBConts.TABLE_DICT.DICT_ID, width: 100, checkbox: true},
                {
                    field: DBConts.TABLE_DICT.DICT_NAME,
                    title: "数据字典名称",
                    sortable: true
                }, {
                    field: DBConts.TABLE_DICT.DICT_TEXT,
                    title: "数据字典内容",
                    sortable: true
                }, {
                    field: DBConts.TABLE_DICT.IS_ENABLE,
                    title: "是否启用",
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value !== '1'){
                            return "不启用";
                        }else{
                            return "启用";
                        }
                    }
                }, {
                    field: DBConts.TABLE_DICT.DATA1,
                    title: "备用字段1",
                    sortable: true
                }, {
                    field: DBConts.TABLE_DICT.DATA2,
                    title: "备用字段2",
                    sortable: true
                }, {
                    field: 'des',
                    title: "描述",
                    sortable: true
                }
            ]]
        });


        $("#dict_add").on('click', function () {
            var params = {};
            params.title = "增加字典";
            params.dlgId="dict_ext_form_dlg_id"
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-application_add';
            params.url = contextRootPath + '/dict/add';
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    dict_datagrid_save('add');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('formIdExt')
                }
            }];

            crud_dlg(params);
        });


            $("#dict_edit").on('click', function () {
                var selected = $('#' + _datagridExt).datagrid('getSelected');


                if (selected == null) {
                    $.messager.alert("提示框", "请选择需要操作的数据字典!", "warning");
                    return;
                }

                var selections = $('#' + _datagridExt).datagrid('getSelections');

                if (selections.length < 1) {
                    $.messager.alert("提示框", "请选择需要操作的数据字典!", "warning");
                    return;
                } else if (selections.length > 1) {
                    $.messager.alert("提示框", "编辑的数据字典为多个，请重新选择!", "warning");
                    return;
                }

                var params = {};
                params.title = "编辑字典";
                params.dlgId="dict_ext_form_dlg_id"
                params.width = 2000;
                params.height = 2000;
                params.top = '10px';
                params.modal = true;
                params.iconCls = 'icon-application_edit';
                params.url = contextRootPath + '/dict/edit?dictId=' + selected[DBConts.TABLE_DICT.DICT_ID];
                params.buttons = [{
                    text: '提交',
                    iconCls: 'icon-application_go',
                    handler: function () {
                        dict_datagrid_save();
                    }
                }, {
                    text: '关闭',
                    iconCls: 'icon-application_side_contract',
                    handler: function () {
                        $('#dict_ext_form_dlg_id').dialog('close');
                    }
                }];

                crud_dlg(params);
            });


            $("#dict_remove").on('click', function () {
                var selections = $('#' + _datagridExt).datagrid('getSelections');
                var ids = "";
                var names = "";

                if (selections.length < 1) {
                    $.messager.alert("提示框", "请选择需要操作的数据字典!", "warning");
                    return;
                }

                $.messager.confirm('确认框', '请确定需要删除所选择的数据字典么？', function (r) {
                    if (r) {
                        $.each(selections, function (i, v) {
                            ids += v[DBConts.TABLE_DICT.DICT_ID] + ",";
                        });

                        $.post(contextRootPath + "/dict/remove?ids=" + ids, function (data) {
                            var params = {};
                            params.element = _datagridExt;
                            params.data = data;
                            params.isClose = false;
                            resultCallback(params);
                        }, 'json');
                    }
                });


            });



        $("#dictTypeAdd").on('click', function () {
            var params = {};
            params.title = "增加字典类型";
            params.dlgId="dict_ext_form_dlg_id"
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-application_add';
            params.url = contextRootPath + '/dict/dictTypeAdd';
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    dict_type_datagrid_save('add');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('formIdExt')
                }
            }];

            crud_dlg(params);
        });

    });


    function getDictByDictType(dtId){
        $("#" + _datagridExt).datagrid({
            queryParams: {
                "dict.dt_id": dtId
            }
        });
    }
</script>

#end



